import Vue from 'vue'
import VueRouter from 'vue-router';
import Layout from '@/components/views/layout/Index.vue';
import Login from '@/components/views/login/Index.vue';
import Home from '@/components/views/layout/home/Index.vue';

const Product = ()=>  import('@/components/views/product/Index.vue')
const ProductList = ()=>  import('@/components/views/product/list/Index.vue')
const ProductCateGory = ()=>  import('@/components/views/product/category/Index.vue')

const User = ()=>  import('@/components/views/user/Index.vue')
Vue.use(VueRouter);

  
const router = new VueRouter({
    routes: [{
      path:'/',
      component: Layout,
      meta: {
        needLogin: true
      },
      children:[{
        path:'/home',
        component:Home,
        name:'home'
      },
      {
        path:'/product',
        component: Product,
        meta: {
          needLogin: true
        },
        children:[{
          path:'product_list',
          component:ProductList,
          name:'product_list'
        },{
          path:'product_category',
          component:ProductCateGory,
          name:'product_category'
        }]
        },
        {
          path:'/user',
          component: User,
          meta: {
            needLogin: true
          }
        }
    ]
      },{
        path:'/login',
        name:'login',
        component: Login
      }],
      mode:'history'
});
console.log("route...")
export default router